# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=cython2
_pkgname=Cython
pkgver=0.29.32
pkgrel=3
pkgdesc='The Cython compiler for writing C extensions for the Python language.'
url='https://pypi.org/project/Cython/#files'
arch=('x86_64' 'aarch64')
license=('Apache')
depends=('python2' 'python2-setuptools')
makedepends=('python2-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('2c21e4f130e33ab79a8c2c71e4e14a443c59f35b2ca8ae675ca4c7ccff9e9d940e6724e1fd79b4b23dd94c769c1a94734802200dd6320d0ec4ac5748472a9b03')

prepare() {
  cd "$_pkgname-$pkgver"

  find . -name '*.py' |
  xargs sed -i -e 's|/usr/bin/env python|/usr/bin/env python2|' \
  -e 's|/usr/bin/python|/usr/bin/python2|'
}

build() {
  cd "$_pkgname-$pkgver"

  python2 setup.py build
}

package() {
  cd "$_pkgname-$pkgver"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  for i in "$pkgdir/usr/bin/"*; do
    mv $i "${i}2"
  done
}

